import { _decorator, Component, Node, v3, Vec2, Vec3 } from 'cc';
import { RoleBase } from './RoleBase';
const { ccclass, property } = _decorator;

@ccclass('Zombie')
export class Zombie extends RoleBase {
    private _doorPosY: number = null;
    private _housePos: Vec3 = new Vec3();
    private _finalPosX: number = null;
    protected _onInit(): void {
        this._finalPosX = -770;
        this._housePos = v3(-1030, -140, 0);
        this._doorPosY = -110;
    }
    onUpdate(dt: number): void {
        //判断僵尸是否到达草地边界
        if (this.node.position.x <= this._finalPosX) {
            let pos = this.node.position.clone();
            //将僵尸的y设置再门口的位置
            this.node.setPosition(pos.x, this._doorPosY, pos.z);
        }
        //判断僵尸是否进入房子，进入房子后需要将其销毁
        if (this.node.position.x >= this._housePos.x) {

        }
    }

    //僵尸移动
    move() {
        this.speed = 80;
        //切换移动动画
        this._stateCtrl.emit("Move");
    }
}